doctype
html
head
	meta(charset="utf-8")
	meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1")
	title 组
	link(rel="stylesheet", href="/plugins/layui/css/layui.css")
	link(rel="stylesheet", href="/plugins/layui/css/modules/layim/msgbox.css")
body
	ul.layim-msgbox#LAY_view
	div(style="margin: 0 15px;")
		blockquote.layui-elem-quote 消息盒子
	.layui-tab(style="margin: 0 15px;")
			ul.layui-tab-title
				li.layui-this 好友分组
				li 聊天群
			.layui-tab-content
				.layui-tab-item.layui-show(type="friendgroup")
					input.layui-input#friendgroup(type="text", name="name", required, lay-verify="required", placeholder="请输入好友分组名称", autocomplete="off" )
				.layui-tab-item(type="group")
					input.layui-input#group(type="text", name="name", required, lay-verify="required", placeholder="请输入群名称", autocomplete="off")
				div(style="padding-top:10px;")
					button.layui-btn.layui-btn-small.layui-btn-primary#create
						i.layui-icon &#xe608;
						添加
					ul.layui-unselect.layim-tab-content.layui-show.layim-list-friend
						each val in data 
							li
								h5
									i.layui-icon &#xe602;
									span #{val.name}
									em
										span (
										cite.layim-count #{val.count ? val.count : 0}
										span )
	script(src="/plugins/layui/layui.js")
	script(type="text/javascript", src="/socket.io/socket.io.js")
	script.
		layui.use(['layim', 'flow', 'element'], function(){
			var layim = layui.layim
			,layer = layui.layer
			,laytpl = layui.laytpl
			,$ = layui.jquery
			,flow = layui.flow;
			var _user = '#{user._id}';
			var _data = '#{data}';
			var element = layui.element();
			$('#create').on('click', function() {
				var type = $('.layui-show').attr('type');
				var name = $('#' + type).val();
				var data = {uid:_user, name:name};
				$.post('/users/im/group/createFriendGroup', data, function(_data) {
					console.log(_data);
					if(_data.code == 0) {
						var _li = $('.layim-list-friend li').eq(0).clone();
						_li.find('.layui-icon').siblings('span').text(_data.data.name);
						_li.find('.layim-count').text(_data.data.count);
						$('.layim-list-friend').append(_li);
					}
				})
			})
		});